package algorithm;

import org.springframework.stereotype.Service;

public class SameLength {
    public StrToInt32 strToInt32;
    public String longestPalindrome(String s) {
        char[] c = s.toCharArray();
        int max = 0;
        int count = 0;
        int tempi = 0;
        int tempj = 0;
        for (int i = 0; i < c.length; i++) {
            for (int j = count; j < i; j++) {
                if (c[i] == c[j]) {
                    count = j + 1;
                    break;
                }
                if (max < i - count + 1) {
                    max = i - count + 1;
//                    tempi = i;
//                    tempj = j;
                }
            }
        }
        return s.substring(tempi, tempj);

//        char[] c=s.toCharArray();
//          for(int i=0;i<c.length;i++){

//           for(int j=count;j<i;j++){
//               if(c[i]==c[j]){
//                   count=j+1;
//                   break;
//               }
//           }
//                   max=Math.max(max,i-count+1);
//          }
//         return max;
    }

    public static void main(String[] args) {
        SameLength sameLength = new SameLength();
        System.out.println(sameLength.longestPalindrome("14654731"));
    }

    public void setStrToInt32(StrToInt32 strToInt32) {
        this.strToInt32 = strToInt32;
    }
}
